var tubeMesh;
var parent = new THREE.Object3D();

function addGeometry( geometry, color ) {

    tubeMesh = THREE.SceneUtils.createMultiMaterialObject( geometry, [
        new THREE.MeshLambertMaterial({
            color: color,
            opacity: geometry.debug ? 0.2 : 0.8,
            transparent: true
        }),
        new THREE.MeshBasicMaterial({
            color: 0x000000,
            opacity: 0.5,
            wireframe: true
    })]);

    if ( geometry.debug ) tubeMesh.add( geometry.debug );

    parent.add( tubeMesh );

    return parent;
}


function makeSplineLeg() {

    var pipeSpline = new THREE.SplineCurve3( [ new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 4, 0 ), new THREE.Vector3( 0, 5, -2 ), new THREE.Vector3( 0, 8, 0 ) ] );

    var segments = 100;

    closed = true;
    debug = false;

    var radiusSegments = 3;

    //THREE.TubeGeometry = function( path, segments, radius, radialSegments, closed ) {
    tube = new THREE.TubeGeometry( pipeSpline, segments, 3, radiusSegments, closed, debug);

    //return addGeometry( tube, 0xff00ff);
    return addGeometry( tube, 0xeebb99);

    //setScale();
}
